import CryptoJS from 'crypto-js';
import moment from 'moment';
const key = CryptoJS.enc.Utf8.parse('/e2801/c8153/cba'); //十六位十六进制数作为秘钥
// 加密
export function aesEncode(raw: any) {
  const iv = CryptoJS.enc.Utf8.parse(moment().format('-YYYY-MM-DD-HH--')); //十六位十六进制数作为秘钥偏移量
  const word = JSON.stringify(raw);
  const srcs = CryptoJS.enc.Utf8.parse(word);
  const encrypted = CryptoJS.AES.encrypt(srcs, key, {
    iv: iv,
    mode: CryptoJS.mode.CBC,
    padding: CryptoJS.pad.Pkcs7,
  });
  return encrypted.ciphertext.toString().toUpperCase();
}
